//
// Created by DengLibin on 2019/1/10 0010.
//
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

/**
 * Z字形变换
L     D     R
E   O E   I I
E C   I H   N
T     S     G
 */

int min_53(int x, int y){
    return x < y ? x : y;
}
string convert(string s, int numRows) {
    if (numRows == 1 || s.length() <= numRows) return s;
    vector<string> rows(min_53(numRows, s.length()));
    int curRow = 0;//当前行
    int goingDown = false;//是否往下走

    for(char c : s){
        rows[curRow] += c;
        if(curRow == 0 || curRow == numRows-1) goingDown = !goingDown; //反转方向
        curRow += goingDown ? 1 :-1;
    }
    string res = "";
    for(string row : rows) res+=row;
    return res;
}
int main53(){

    cout << convert("A",4);
    return 0;
}


